﻿using UnityEngine;
using System.Collections;

public class BulletFire : MonoBehaviour {
    [HideInInspector]
    public int attack;
    GameObject hitPrefab;
     static Vector3 hitoffset = new Vector3(0, 0.2f);
	// Use this for initialization
	void Start () {
        hitPrefab = Resources.Load<GameObject>("FX/hitFX");
	}
	
	// Update is called once per frame
	void Update () {
	
	}
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag=="Enemy")
        {
            collider.GetComponent<Enemy>().OnDamage(attack);
           GameObject go= GameObject.Instantiate(hitPrefab);
            go.transform.position = transform.position+ hitoffset;
            Destroy(go, 0.5f);
        }
    }
}
